class MainMenu extends GuaScene {
    constructor(game) {
        super(game)
        this.setup()
    }

    setup() {
        this.setupBG()
        this.setupInputs()

    }





    update() {
        super.update();
    }

    draw() {
        super.draw()

    }

// setup 系列

    setupSeedChooserBack() {
        let b1 = PlantCard.new(this.game, 'seedChooser_Background')
        b1.x = 200
        b1.y = 100
        this.addElement(b1)
        for (let c of this.cards) {
            this.plantCard.push(c)
        }
        for (let i = 0; i < this.plantCard.length; i++) {
            this.addPlantchooseCard(this.plantCard[i], i)
        }
        this.addStartButton('start_leave')

    }

    addStartButton(name) {

        let start = PlantCard.new(this.game, name)
        start.x = 260
        start.y = 550
        this.addElement(start)
        this.start = start
    }

    setupBG() {
        let bg = PlantIcon.new(this.game, 'main_menu')
        this.addElement(bg)

        let adventure = PlantIcon.new(this.game, 'adventure_0')
        adventure.x = 680
        adventure.y = 100
        this.addElement(adventure)
    }


    setupInputs() {
        // mouse inputs
        let self = this
        this.game.registerMouse(function (event, status) {
            let x = event.offsetX
            let y = event.offsetY
            if (status === 'down') {
                if (x > 680 && x < 850 && y > 100 && y < 170) {
                    self.updateScene()
                }
            }
        })

    }


// update 系列
    updateScene() {
        sleep(500).then(() => {
            let s = ChooseLevel.new(this.game)
            this.game.replaceScene(s)
        })
    }

}
